<?php
abstract class LastFmAbstract
{
    protected $api_key    = null;
    
    /*
     * @TODO find a better way to handle the api_key
     */
    public function  __construct()
    {
        $this->api_key      = 'b0d5954a3611b0e4acd36531fb1703cb';
        
    }
    
    /*
     * @author  Luis Milanese
     * @param   Array
     * @return  Array
     */
    public function request($args)
    {

        $url = 'http://ws.audioscrobbler.com/2.0/?method=';
        $url .= $args['method'];
        unset($args['method']);
        
        if(!is_null($this->api_key))
            $url .= '&api_key=' . $this->api_key;

        if(!is_null($this->secret_key))
            $url .= '&secret_key=' . $this->secret_key;

        
        foreach($args as $i => $arg)
        {
            $url .= '&' . $i . '=' . $arg;
        }

        $xml = file_get_contents($url);
        return simplexml_load_string($xml);
    }
    
}
?>
